package com.feeyo.groundservice.base.redis;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

import com.feeyo.groundservice.base.util.PropertiesUtils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedisPool;

import java.util.LinkedList;

/**
 * Created by fooevr on 2016/12/26.
 */
public class Redis extends AbstractVerticle {
    public static ShardedJedisPool pool = null;
    @Override
    public void start(Future<Void> startFuture) throws Exception {
        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
        JedisShardInfo si = new JedisShardInfo(PropertiesUtils.getProperty("redis.host"), Integer.parseInt(PropertiesUtils.getProperty("redis.port")));
        pool = new ShardedJedisPool(config, new LinkedList<JedisShardInfo>(){{add(si);}});
        startFuture.complete();
        
    }
}
